<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      var num = parseInt(Math.random() * 9 + 1);
      while (num) {
        var num1 = prompt('请猜一个数字');
        if (num1 > num ) {
            alert ('您猜大了，请继续');
        } else if (num1 < num) {
            alert ('您猜小了，请继续');
        } else {
            alert ('您猜对了');
            break;
        }
      }
    </script>
</body>
</html>